package ch09;

public class TimeDepositAccount extends SavingsAccount{
	
	private double withdrawlPenalty = 20;
	private int withdrawlPenaltyTime = 6;
	
	public TimeDepositAccount(double rate) 
	{  
		super(rate);
	}
	
	public void addInterest() 
	{  
		if(withdrawlPenaltyTime > 0){
			withdrawlPenaltyTime --;
			if(withdrawlPenaltyTime == 0){
				withdrawlPenalty = 0;		
			}
		} 
		double interest = getBalance() * getInterestRate() / 100;
		deposit(interest); 
	}
	
	public void withdraw(double amount) 
	{  
		super.withdraw(amount + withdrawlPenalty);
	}

}
